package com.whub507.msgmanager.security.config;

import com.whub507.msgmanager.security.interceptor.WebInterceptor;
import com.whub507.msgmanager.security.service.UserService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Bean
    public WebInterceptor webInterceptor(){
        return new WebInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //定义排除swagger访问的路径配置
        String[] swaggerExcludes=new String[]{"/swagger-ui.html/**","/swagger-resources/**","/webjars/**"};
        //自定义去除的路径
        String[] myExcludes=new String[]{"/logout","/login"};
        registry.addInterceptor(webInterceptor())
                .addPathPatterns("/msg/**")
                .addPathPatterns("/project/**");
        WebMvcConfigurer.super.addInterceptors(registry);
    }


}
